﻿<!DOCTYPE html>
<html lang="zh_CN">
<%@ include  file="../header.jsp"%>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta http-equiv="Content-Language" content="zh-CN"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="shop">
    <meta name="author" content="letsun">

    <title>商品列表</title>

    <link rel="stylesheet" type="text/css" href="${resources}/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="${resources}/plugs/fontAwesome/4.6.3/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="${resources}/css/jquery.gritter.css"/>
    <link rel="stylesheet" type="text/css" href="${resources}/css/main.css"/>
    <link href="${resources}/css/foot.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/goodslist.css" rel="stylesheet" type="text/css">
    <link href="${resources}/css/goodsSearchList.css" rel="stylesheet" type="text/css">

    <script src="${resources}/js/jquery.min.js"></script>
    <script src="${resources}/js/bootstrap.min.js"></script>
    <script src="${resources}/js/jquery.gritter.min.js"></script>
    <script src="${resources}/js/jquery.gritter.min.extend.js"></script>
    <script src="${resources}/js/jqPaginator.min.js"></script>

    <style>
        .col-md-12 {
            margin: 0;
            padding: 0;
        }
    </style>

    <style>
        /* fix */
        body {
            background-color: #FFF;
        }

        .thumbnail {
            height: 380px;
            max-height: 380px;
        }

        .goods-title a {
            font-weight: bolder;
            color: #666;
        }

        /* 特征 */
        .stamp {
            left: 10px;
            margin: 5px;
            overflow: hidden;
            position: absolute;
            top: 5px;
            z-index: 5;
            width: 45px;
            height: 45px;
            display: block;
            background: #00ccff;
            color: #fff;
        }
      
        .goods-area {
		    position: relative;
		    padding-bottom: 60px;
	    }

        .pageBtn {
            position: absolute;
            bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            left: 50%;
            -webkit-transform: translate(-50%, 0);
            -moz-transform: translate(-50%, 0);
            -ms-transform: translate(-50%, 0);
            -o-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }

        .pageBtn li {
            width: 40px;
            height: 40px;
            float: left;
            border-right: 1px solid #ccc;
            text-align: center;
            line-height: 40px;
        }

        .pageBtn li:last-child {
            border: none;
        }

        .pageBtn .prev, .pageBtn .next {
            width: 60px;
        }
        
        .pageBtn .active{
        	background-color: #337ab7;
        	color: #fff;
        }
    </style>
</head>


<body>




<!--面包屑-->
<div class="crumbs-area" style="border-bottom: 0px solid #CCC;">
    <ul>
        <li>
            <a href="${path}/commodity/goodslist">全部</a>
        </li>
        <c:if test="${categoryName !=null}">
	        <li>
	            <i class="fa fa-angle-double-right"></i>
	            <a href="javascript:void(0)">${categoryName}</a>
	        </li>
        </c:if>
    </ul>
</div>
<!-- 面包屑 -->



<div class="goods-area">
    <ul id="pageCon">
     
    </ul>
</div>

<%@ include file="../footer.jsp" %>
<script type="text/javascript">
    var $path = "/shop-pc";
</script>


<script type="text/javascript">
   
	var selData = ({
		categoryId : '${categoryId}',
		name:'${name}',
		pageNumber : 1
	})
   
    function paging(cfg) {
        var paginator = $("#pageCon");

        paginator.jqPaginator({
            totalCounts: 500,//总条目数
            pageSize: 10,//每一页显示的条目数
            visiblePages: 5,//分多少页
            currentPage: 1,//当前页数
            first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
            last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
            wrapper: '<ul class="pageBtn"></ul>',

            //页面加载和点击页码时请求数据
            onPageChange: function (num) {
            	selData.pageNumber= num;
                $.get(cfg.url, selData, function (res) {
                    if (res.msg == 0) {
                        $("#pageCon").html('<p style="padding: 20px;text-align: center">暂无商品！</p>');
                        return;
                    }

                    var html = "";

                    //重新配置分页的总条目数
                    var count = -(res.msg) * (-1);
                    paginator.jqPaginator('option', {
                        totalCounts: count
                    });

                    for (var i = 0; i < res.result.length; i++) {
                    	
                        html+='<li>';
                        html+='<div class="good-panel">';
                        html+='<div class="good-inner">';
                        html+='<a href="${path}/commodity/info?goodsId='+res.result[i].id+'" target="_blank">';
                        html+='<img src="'+res.result[i].picurl+'" data-holder-rendered="true" style="display: block;">';
                        html+='</a>';
                        html+='<p class="good-inner-prize"><span>￥'+res.result[i].price+'</span></p>';
                        html+=' <p class="good-inner-title">'+res.result[i].name+'</p>';
                        html+='<p class="good-inner-other">剩余:<span>'+res.result[i].remain+'</span><b>|</b><a>销量:'+res.result[i].sales+'</a></p>';
                        html+=' </div>';
                        html+='</div>';
                        html+=' </li>';
                    }

                    $("#pageCon").append(html);
                });
            }
        });
    }
    paging({url: "${path}/commodity/list"});
</script>
</body>
</html>
